﻿@model IEnumerable<Models.ClientProfile>

@{
    ViewBag.Title = "Client Profiles";
    Layout = "~/Views/Shared/_Layout.cshtml";
    int cp_index_serial = 1;
}

<div class="box-body table-responsive no-padding">
    <table class="table table-bordered table-hover table-striped">
        <tr>
            <th style="width:50px;" valign="middle">
                <div class="btn-group-xs">
                    <a title="Create a new profile" href="@Url.Action("Create")" class="btn btn-info"><i class="fa fa-plus"></i>&nbsp;New</a>
                </div>
            </th>
            <th>Name</th>
            <th>NRIC</th>
            <th>Age</th>
            <th>Gender</th>
            <th>Race</th>
            <th style="min-width:100px;">Tagging Info</th>
            <th>Family Contact</th>
            <th style="min-width:100px;">Medical Condition</th>
            <th style="min-width:100px;">&nbsp;</th>
        </tr>

        @foreach (var item in Model)
        {
            <tr>
                <td align="right">@(cp_index_serial++).</td>
                <td>@Html.DisplayFor(modelItem => item.Name)</td>
                <td>
                    @Html.DisplayFor(modelItem => item.NRIC)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Age)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Gender.Name)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Race.Name)
                </td>
                <td style="min-width:90px;">
                    @{
                        if (item.AccufindTaggingInfoes != null && item.AccufindTaggingInfoes.Count() > 0)
                        {
                            foreach (string existingTag in item.AccufindTaggingInfoes.Select(t => t.Name))
                            {
                                <span class="label label-default">@existingTag</span>
                            }
                        }
                    }
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.FamilyContactNo)
                </td>
                <td style="min-width:100px;">
                    @Html.DisplayFor(modelItem => item.MedicalCondition, new { @class = "text-truncate" })
                </td>
                <td class="text-center to-mid" style="min-width:100px;">
                    <div class="btn-group-xs">
                        <a title="Edit" href="@Url.Action("Edit",new { id = item.ClientProfileId })" class="btn btn-success"><i class="fa fa-edit"></i></a>
                        <a title="Details" href="@Url.Action("Details",new { id = item.ClientProfileId })" class="btn btn-warning"><i class="fa fa-search"></i></a>
                        <a title="Delete" href="@Url.Action("Delete",new { id = item.ClientProfileId })" class="btn btn-danger"><i class="fa fa-trash"></i></a>
                    </div>
                </td>
            </tr>
        }
    </table>
</div>
